'''
Company: TWL
Author: xue jian
Email: xuejian@kanzhun.com
Date: 2020-11-28 15:48:03
'''
#
# @lc app=leetcode.cn id=493 lang=python3
#
# [493] 翻转对
#

# @lc code=start
from typing import List
class Solution:
    def reversePairs(self, nums: List[int]) -> int:
        pre=[]
        ans=0
        import bisect
        for v in nums:
            ans+=len(pre)-bisect.bisect_right(pre, 2*v)
            bisect.insort(pre, v)
        return ans
        
# @lc code=end

